/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import common.Config;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author nicolas
 */
public class Server {

    static final int PORT = Integer.parseInt(Config.getProperty().getProperty("server.port"));  // port for this server
    private VisitorsGroup visitorsGroup;

    public Server() // wait for a client connection, spawn a thread, repeat
    {
        visitorsGroup = new VisitorsGroup();
        try {
            ServerSocket serverSock = new ServerSocket(PORT);
            Socket clientSock;

            while (true) {
                System.out.println("Waiting for a client...");
                clientSock = serverSock.accept();
                new ServerHandler(clientSock, visitorsGroup).start();
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }  // end of ChatServer()
    // -----------------------------------

    public static void main(String args[]) {
        new Server();
    }
}
